package com.zxx.pattern.statePattern.state;

/**
 * 没有投币的状态
 * @author zxx on 2021/1/14
 */
public class StateNoMoney implements State {

    private CandyMachine candyMachine;

    public StateNoMoney(CandyMachine candyMachine) {
        this.candyMachine = candyMachine;
    }

    @Override
    public void onMoneyInserted() {
        System.out.println("投币成功！");
        candyMachine.setState(candyMachine.getMoneyInsertedState());
    }

    @Override
    public void onMoneyReturned() {
        //将钱退回
        System.out.println("还没有投币！操作无效！");
    }

    @Override
    public void onCrankTurned() {
        //转动摇把
        System.out.println("还没有投币！操作无效！");
    }

    @Override
    public void onCandyPoped() {
        //给出糖果
        System.out.println("还没有投币！操作无效！");
    }
}
